﻿using System.Web;
using System.Web.Mvc;
using Microsoft.Owin.Security;
using Microsoft.Practices.Unity;
using Service.Interface;
using WebSite.Admin.Identity;

namespace WebSite.Admin.Core
{
    [Authorize]
    public class IdentityController : Controller
    {
        [Dependency]
        protected ISysUserService SysUserService { get; set; }

        private AppSignInManager _signInManager;
        private AppUserManager _userManager;

        protected AppSignInManager SignInManager
        {
            get
            {
                return _signInManager=_signInManager ?? new AppSignInManager(UserManager,AuthenticationManager);
            }
        }

        protected AppUserManager UserManager
        {
            get
            {
                return _userManager=_userManager ?? new AppUserManager(SysUserService);
            }
        }

        public IAuthenticationManager AuthenticationManager
        {
            get { return HttpContext.GetOwinContext().Authentication; }
        }
    }
}